home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Grafik & Text & Film / Quark XTensions / Freeware Xtensions / Quark AppleScript Scripts / Scripts (text only) / Fit Box to Picture < prev    next >
Text File  |  1994-05-02  |  3KB  |  74 lines

  1. --Copyright 1994 Quark, Inc.   All rights reserved.
  2.  
  3.  
  4. tell application "QuarkXPress™"
  5.     activate
  6.     if exists (document 1) then
  7.         tell document 1
  8.             if exists (current box) then
  9.                 if (box type of current box ≠ picture box) then
  10.                     display dialog "Please select a picture box before running this script." buttons {"Cancel"} default button 1 with icon stop
  11.                 end if
  12.                 
  13.                 set hm to horizontal measure
  14.                 set vm to vertical measure
  15.                 if hm ≠ points and vm ≠ points then
  16.                     set properties to {horizontal measure:points, vertical measure:points}
  17.                 end if
  18.                 
  19.                 tell current box
  20.                     set bnds to bounds of it as list
  21.                     set bnds1 to item 1 of bnds as real
  22.                     set bnds2 to item 2 of bnds as real
  23.                     set boxrot to rotation as real
  24.                     set boxskew to skew as real
  25.                     if boxskew ≠ 0 or boxrot ≠ 0 then
  26.                         display dialog "This script cannot process skewed and/or rotated picture boxes." buttons {"Cancel"} default button 1 with icon stop
  27.                     end if
  28.                     
  29.                     tell image 1
  30.                         set grfkbnds to bounds
  31.                         set grfkbnds3 to item 3 of grfkbnds as real
  32.                         set grfkbnds4 to item 4 of grfkbnds as real
  33.                         set grfkscle to scale as list
  34.                         set grfkscle1 to (item 1 of grfkscle as real) / 100
  35.                         set grfkscle2 to (item 2 of grfkscle as real) / 100
  36.                         set grfkofst to offset as list
  37.                         set grfkofst1 to item 1 of grfkofst as real
  38.                         set grfkofst2 to item 2 of grfkofst as real
  39.                         set rot to angle as real
  40.                         set grfkskew to skew as real
  41.                         if grfkbnds = {0, 0, 0, 0} then
  42.                             display dialog "There is no picture in this picture box." buttons {"Cancel"} default button 1 with icon stop
  43.                         end if
  44.                     end tell
  45.                     
  46.                     set var1 to (bnds1 + grfkofst1) as real
  47.                     set var2 to (bnds2 + grfkofst2) as real
  48.                     set var3 to (bnds1 + grfkofst1 + (grfkbnds4 * grfkscle1)) as real
  49.                     set var4 to (bnds2 + grfkofst2 + (grfkbnds3 * grfkscle2)) as real
  50.                     
  51.                     try
  52.                         set properties to {bounds:{var1, var2, var3, var4}, rotation:rot, skew:grfkskew}
  53.                         tell image 1
  54.                             set properties to {offset:{0, 0}, angle:0, skew:0}
  55.                         end tell
  56.                     on error
  57.                         set properties of document 1 to {horizontal measure:hm, vertical measure:vm}
  58.                         display dialog "The item can't be positioned off the pasteboard." buttons "Cancel" default button 1 with icon stop
  59.                     end try
  60.                 end tell
  61.                 
  62.                 if hm ≠ points and vm ≠ points then
  63.                     set properties to {horizontal measure:hm, vertical measure:vm}
  64.                 end if
  65.                 
  66.             else
  67.                 display dialog "Please select a picture box before running this script." buttons {"OK"} default button 1 with icon note
  68.             end if
  69.         end tell
  70.     else
  71.         display dialog "Please open a QuarkXPress™ document before running this script." buttons "Cancel" default button 1 with icon stop
  72.     end if
  73. end tell
  74.